package gui;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class StartupSettingsManager {
	
	private static final String filepath = "./settings";
	
	private String [] paths = new String[2];
	
	
	public StartupSettingsManager() { }
	
	public String getPath(int i) {
		if (i != 0 || i != 1) {
			//błąd
		}
		return paths[i];
	}
	
	public void setPath(String path, int i) {
		paths[i] = path;
	}
	
	public void saveToFile() throws IOException {
		BufferedWriter writer = new BufferedWriter(new FileWriter(filepath));
		for (String s : paths) {
			writer.write(s);
			writer.newLine();
		}
		writer.close();
	}
	
	public boolean loadFromFile() throws IOException {
		BufferedReader reader = new BufferedReader(new FileReader(filepath));
		for (int i = 0; i < 2; i++) {
			paths[i] = reader.readLine();
		}
		reader.close();
		//TODO walidacja
		if (paths[0].isEmpty()) {
			return false;
		}
		return true;
	}

}
